1
The Spectrum of Control Flow: From Sequential to Exceptional
AI031 Lesson 8
00:00

Standard control flow is a predictable march: the program counter moves from address $a_k$ to $a_{k+1}$ based on sequential logic or explicit jumps. However, Exceptional Control Flow (ECF) represents the "abrupt" transitions that occur outside this normal stream.

1. The Mathematical Model

Processor execution is a sequence $a_0, a_1, \dots, a_{n-1}$, where each $a_k$ corresponds to an instruction $I_k$. ECF breaks this chain when a change in processor state—an event—triggers a jump to a specialized handler not found in the application's immediate code path.

2. Implementation Levels

ECF bridges the gap between hardware and software. It ranges from hardware-level exceptions (faults, interrupts) to OS-level context switching and signals.

Figure 8.1: Anatomy of an Exception Normal Flow (Skipped) Sequential Flow (Iₖ) Event! Exception Handler Optional Return (Iₖ₊₁)

3. The "Abrupt" Reality

Whether it is a user hitting Ctrl+C or a system call requesting disk access, ECF forces the CPU to jump to a different "world"—the kernel—ensuring the system remains responsive to dynamic state changes.

main.py
TERMINAL bash — 80x24
> Ready. Click "Run" to execute.
>